/****************************************************************
This is STATA code for USA federal income tax code, 
under "head of household"
*****************************************************************/

*by Xiaodong Fan, fanxiaodong@gmail.com
*Sept 2016.

#delimit ;

cap program drop p_usa_ftax_2004;
program define p_usa_ftax_2004;
   local v_pretax `1';
   local v_posttax `2';
   replace `v_posttax' = `v_pretax' if `v_pretax' <=0;
   replace `v_posttax' = 0.9235 * `v_pretax' if `v_pretax' >0 & `v_pretax' <= 10250;
   replace `v_posttax' = 9465.88+0.8235*(`v_pretax'-10250) if `v_pretax' >10250 & `v_pretax' <=20450;
   replace `v_posttax' = 17865.58+0.7735*(`v_pretax'-20450) if `v_pretax' >20450 & `v_pretax' <=49150;
   replace `v_posttax' = 40065.03+0.6735*(`v_pretax'-49150) if `v_pretax' >49150 & `v_pretax' <=87900;
   replace `v_posttax' = 66163.15+0.7355*(`v_pretax'-87900) if `v_pretax' >87900 & `v_pretax' <=110750;
   replace `v_posttax' = 82969.33+0.7055*(`v_pretax'-110750) if `v_pretax' >110750 & `v_pretax' <=172950;
   replace `v_posttax' = 126851.43+0.6555*(`v_pretax'-172950) if `v_pretax' >172950 & `v_pretax' <=329350;
   replace `v_posttax' = 229371.63+0.6355*(`v_pretax'-329350) if `v_pretax' >329350 & `v_pretax' <.;
end;


